var prefs__MODULE_ID__;

// debug flag. When its value is non-zero, debugging messages are displayed
var debug = 0;
// The string containing debugging messages
var debug_html = "";
      
function loadPhotos() {
	printDebugMsg("Entered js code!");
	prefs__MODULE_ID__ = new _IG_Prefs(__MODULE_ID__);
	index__MODULE_ID__ = 0;
	var username = prefs__MODULE_ID__.getString("username");
	var maxPhotos = prefs__MODULE_ID__.getInt("maxphotos");
	baseUrl = "http://picasaweb.google.com/data/feed/api/user/" + username;
	feed = baseUrl + "?kind=photo&alt=rss&max-results="+maxPhotos;
	printDebugMsg("consuming <a href='"+feed+"'>feed</a>");
	//encodeURIComponent
	var flashArgs = "host=picasaweb.google.com&RGB=0xFFFFFF&feed="+encodeURIComponent(feed);
	_gel("slideshow__MODULE_ID__").innerHTML = "<embed type='application/x-shockwave-flash' src='http://picasaweb.google.com/s/c/bin/slideshow.swf' width='310' flashvars='"+flashArgs+"' pluginspage='http://www.macromedia.com/go/getflashplayer'></embed>";
}

// Outputs debug messages if debug flag has a non-zero value
function printDebugMsg(msg) {      
  if (debug) {
    debug_html += msg + "<br/>";
    // Write debug HTML to div
    _gel("debug_div").innerHTML = debug_html;
  }
}

_IG_RegisterOnloadHandler(loadPhotos);
